﻿@using System.Web.Mvc
@using DMS.BO.Models
@using DMS.Configuration
@using DMS.Entities


@helper RenderPagerScript(SearchResult searchResult, string pagerSelector, string formSelector, string hiddenSelector = "#PageIndex")
{
    @MvcHtmlString.Create("<script type=\"text/javascript\">")
    <text>
    $().ready(function() {                 
            $('@pagerSelector').pager({
                pagenumber: @(searchResult.Filter.PageIndex),
                pagecount: @(searchResult.TotalPages),
                buttonClickCallback: function(pageIndex) {
                    $('@(hiddenSelector)').val(pageIndex);                  
                    @if (string.IsNullOrWhiteSpace(formSelector))
                    {
                        <text>$(this).parents('form').submit();</text>
                    }
                    else
                    {
                        <text>$('@formSelector').submit();</text>
                    }
    }
            }); 
        });        
    </text>
    @MvcHtmlString.Create("</script>")
}


